from arduino import Arduino
import time

b = Arduino("COM3")
redPin1 = 2;
redPin2 = 5;
redPin3 = 8;
redPin4 = 11;
redPin5 = 13;

bluePin1 = 3;
bluePin2 = 6;
bluePin3 = 9;
bluePin4 = 44;
bluePin5 = 45;

greenPin1 = 4;
greenPin2 = 7;
greenPin3 = 10;
greenPin4 = 12;
greenPin5 = 46;

#declare output pins as a list/tuple
b.output([redPin1,redPin2,redPin3,redPin4,redPin5,
          bluePin1,bluePin2,bluePin3,bluePin4,bluePin5,
          greenPin1,greenPin1,greenPin1,greenPin1,greenPin1])

#initialize the leds to off
b.analogWrite(redPin1, 255)
b.analogWrite(redPin2, 255)
b.analogWrite(redPin3, 255)
b.analogWrite(redPin4, 255)
b.analogWrite(redPin5, 255)

b.analogWrite(greenPin1, 255)
b.analogWrite(greenPin2, 255)
b.analogWrite(greenPin3, 255)
b.analogWrite(greenPin4, 255)
b.analogWrite(greenPin5, 255)

b.analogWrite(bluePin1, 255)
b.analogWrite(bluePin2, 255)
b.analogWrite(bluePin3, 255)
b.analogWrite(bluePin4, 255)
b.analogWrite(bluePin5, 255)

#keep prompting user for red, green, and blue value until they exit out of the loop
#send the values to the arduino
loop = 1
while (loop == 1):
    brightnessred = input('Red Value: ')
    brightnessgreen = input('Green Value: ')
    brightnessblue = input('Blue Value: ')
    loop = input('Loop?(1/0): ') 

    b.analogWrite(redPin1, 255-brightnessred)
    b.analogWrite(redPin2, 255-brightnessred)
    b.analogWrite(redPin3, 255-brightnessred)
    b.analogWrite(redPin4, 255-brightnessred)
    b.analogWrite(redPin5, 255-brightnessred)

    b.analogWrite(greenPin1, 255-brightnessgreen)
    b.analogWrite(greenPin2, 255-brightnessgreen)
    b.analogWrite(greenPin3, 255-brightnessgreen)
    b.analogWrite(greenPin4, 255-brightnessgreen)
    b.analogWrite(greenPin5, 255-brightnessgreen)

    b.analogWrite(bluePin1, 255-brightnessblue)
    b.analogWrite(bluePin2, 255-brightnessblue)
    b.analogWrite(bluePin3, 255-brightnessblue)
    b.analogWrite(bluePin4, 255-brightnessblue)
    b.analogWrite(bluePin5, 255-brightnessblue)

